package com.seven.system.service.Impl;

import com.seven.enity.Role;
import com.seven.system.dao.RoleDao;
import com.seven.system.service.RoleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author longlong
 * @date 2024/3/8 16:05
 * description
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Resource
    private RoleDao roleDao;
    @Override
    public List<Role> selectAll() {
        List<Role> roles = roleDao.selectList(null);
        return roles;
    }

    @Override
    public List<String> selectByUserId(String userId) {
        return roleDao.selectByUserId(userId);
    }

    @Override
    @Transactional
    public void qrfp(String userId, String[] roleIds) {
        //1.删除该用户原来的角色
        roleDao.deleteByUserId(userId);
        //2. 添加新的角色
        roleDao.batchInsert(userId,roleIds);

    }
}
